<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath %>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>登录</title>
		<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="css/login.css" />
	</head>

	<body class="beg-login-bg">
		<div class="beg-login-box">
			<header>
				<h1 align="center" style="font-size: 25px">RSS管理系统登录</h1>
			</header>
			<div class="beg-login-main">
				<form action="loginkis" class="layui-form" method="post">
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        <i class="layui-icon">&#xe612;</i>
                    </label>
						<input type="text" name="loginname" lay-verify="required" autocomplete="off" placeholder="这里输入登录名" class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        <i class="layui-icon">&#xe642;</i>
                    </label>
						<input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="这里输入密码" class="layui-input">
					</div>
					<div class="layui-form-item">
						<div class="beg-pull-left beg-login-remember">
							<div class="layui-btn layui-btn-primary" id="reg"><i class="layui-icon">&#xe650;</i> 注册</div>
                        </div>
						<div class="beg-pull-right">
							<button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
                            <i class="layui-icon">&#xe650;</i> 登录
                        </button>
						</div>
						<div class="beg-clear"></div>
					</div>
				</form>
			</div>
			<footer>
				<p align="center">2017 © 版权信息</p>
			</footer>
		</div>
		<script type="text/javascript" src="plugins/layui/layui.js"></script>
		<script>

			layui.use(['layer', 'form'], function() {
				var layer = layui.layer,
					$ = layui.jquery,
					form = layui.form();
				$("#reg").on("click",function(){
					location.href = "reg";
				});
				form.on('submit(login)',function(data){
				     $.ajax({
							type: 'post',
							url:  'user/login',
							data: data.field,
							dataType: 'json',
							success: function(ret, status, xhr) {
								if(ret.isOk) {
									location.href = "index";
									return ;
								}
								if (ret.isFail) {
									layer.msg(ret.msg, {
												shift: 6
												, shade: 0.3
												, time: 2500
												, offset: "165px"
												, closeBtn: 1
												, shadeClose: true
											}) ;
								}
								// Validator 层验证失败
								if (ret.userNameMsg) {
									layer.msg(ret.userNameMsg);
								}
								if (ret.passwordMsg) {
									layer.msg(ret.passwordMsg);
								}
						}
				     });
					// location.href='login';
					return false; 
				});
				
				
			});
			
		</script>
	</body>
</html>